home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / v3_1 / sbp3_1e.lzh / ELECTION.PL < prev    next >
Text File  |  1991-10-31  |  2KB  |  72 lines

  1. /* From the book PROLOG PROGRAMMING IN DEPTH
  2.    by Michael A. Covington, Donald Nute, and Andre Vellino.
  3.    Copyright 1988 Scott, Foresman & Co.
  4.    Non-commercial distribution of this file is permitted. */
  5. /* Modified for Quintus Prolog by Andreas Siebert */
  6.  
  7. /* ELECTION.PRO */
  8. /* For use with DREASON.PRO */
  9.  
  10. /*
  11.  * N.B.: this file will not reconsult properly
  12.  * in Arity or certain other Prologs.
  13.  */
  14.  
  15. :- no_style_check(discontiguous).
  16. :- dynamic (neg)/1, supports/2, runs/1.
  17. :- multifile (neg)/1.
  18.  
  19. nominate(free_traders,hunter) := true.
  20.  
  21. nominate(free_traders,farmer) :=
  22.      neg nominate(free_traders,hunter).
  23.  
  24. nominate(free_traders,baker) :=
  25.      neg nominate(free_traders,hunter),
  26.      neg nominate(free_traders,farmer).
  27.  
  28. neg nominate(free_traders,hunter) :=
  29.      neg supports(gardener,hunter).
  30.  
  31. nominate(isolationists,fox) :=
  32.      neg runs(bull),
  33.      neg nominate(free_traders,hunter).
  34.  
  35. nominate(isolationists,bull) :=
  36.      runs(bull),
  37.      supports(crow,fox).
  38.  
  39. nominate(isolationists,hart) :=
  40.      neg nominate(isolationists,bull),
  41.      neg nominate(isolationists,fox).
  42.  
  43. elected(Candidate1) :=
  44.      nominate(free_traders,Candidate1),
  45.      nominate(isolationists,Candidate2),
  46.      supports(crow,Candidate2).
  47.  
  48. elected(bull) :=
  49.      nominate(isolationists,bull),
  50.      nominate(free_traders,Candidate),
  51.      neg supports(gardener,Candidate).
  52.  
  53. supports(gardener,baker).
  54.  
  55. supports(crow,fox).
  56.  
  57. neg supports(Politician,Candidate2) :-
  58.      supports(Politician,Candidate1),
  59.      Candidate2 \= Candidate1.  /* \= is defined in dreason.pl */
  60.  
  61. runs(hunter).
  62.  
  63. runs(farmer).
  64.  
  65. runs(baker).
  66.  
  67. runs(fox).
  68.  
  69. runs(hart).
  70.  
  71. neg runs(bull) := true.
  72.